/**
 *  DFRduino library for onboard input/output modules. These include 7 tactile
 *  buttons and an h-bridge for DC motors. Note that the following pins will
 *  be used by this library under the specified conditions:
 *
 *      A7: Used for buttons 1-5 (always)
 *      D2,D3: Used for button 6,7 respectively when digital buttons enabled
 *      D4,D5: Used for motor 1 when enabled
 *      D6,D7: Used for motor 2 when enabled
 *
 *  NOTE: DFRduino::stop() will always analogWrite(#, LOW) to pins 5,6.
 *  NOTE: DFRduino::enable_motor#() will also stop the specified motor
 */
#ifndef DFRduino_h
#define DFRduino_h

#include "Arduino.h"

/* DFRduino Key Variables */
#define KEYPIN   7
#define NUM_KEYS 5
#define KEYPIN_6 2
#define KEYPIN_7 3

/* DFRduino Motor Variables */
#define E1 5     //M1 Speed Control
#define E2 6     //M2 Speed Control
#define M1 4    //M1 Direction Control
#define M2 7    //M1 Direction Control
#define MOTOR_FWD  0
#define MOTOR_BKD  1

class DRFduino {
  
  public:
  /* DFRduino Key Methods */
  void enable_digital_buttons();
  void disable_digital_buttons();
  int get_key_press();

  /* DFRduino Motor Methods */
  void enable_motor1();
  void enable_motor2();
  void disable_motor1();
  void disable_motor2();
  void motor1_go(int direction, int rate);
  void motor2_go(int direction, int rate);
  void motors_stop();
  
  
  private:
  /* DFRduino Key Variables */
  int adc_key_val[5] = { 30, 150, 360, 535, 760 };
  int oldkey=-1;
  char enable_digital = 0;
  /* DFRduino Key Methods */
  int convert_key(unsigned int input);

  /* DFRduino Motor Variables */
  char enable_motor1 = 0;
  char enable_motor2 = 0;
  char turn_on_point = 0;
}
#endif

